//搜索栏随滚动部分固定效果
window.onload = function(){    //window.onload表示网页加载完成后执行
   
    window.onscroll=function(){    //document.onscroll表示滚动条滚动时执行
        let s1 = document.documentElement.scrollTop;    //获取滚动条滚动的距离
        let s2 = document.body.scrollTop;
        let scroll = s1 ==0 ? s2 : s1;    //获取滚动条滚动的距离
        let width = document.documentElement.clientWidth;    //获取屏幕宽度
        let search = document.getElementById('fixedbox');    //获取搜索栏
        console.log(111);
        if(scroll>width*0.12)
        {
            search.style.position = "fixed";    //固定搜索栏
            search.style.top = "0";  
            search.style.left = "0";
        }
        else{
            search.style.position = "static";    //搜索栏不固定
        }
    }

    const tans_to_business_bt = document.querySelectorAll('.tansto');    //获取跳转到商家信息页面的按钮
    tans_to_business_bt.forEach((button, index) => {    //遍历按钮
        button.onclick = function() {    //点击按钮时执行
            console.log("Button clicked, redirecting to businessInfo.html"); // 添加调试信息
            window.location.href = "businessInfo.html";    //跳转到商家信息页面
        }
    });

    const tans_to_list_bt = document.querySelectorAll('.transto_list');    //获取跳转到商家信息页面的按钮
    tans_to_list_bt.forEach((button, index) => {    //遍历按钮
        button.onclick = function() {    //点击按钮时执行
            console.log("Button clicked, redirecting to businessList.html"); // 添加调试信息
            window.location.href = "businessList.html";    //跳转到商家信息页面
        }
    });
}